//
//  NSObjectViewController.m
//  KnowledgeHierarchy
//
//  Created by linyi on 2020/4/12.
//  Copyright © 2020年 linyi. All rights reserved.
//

#import "NSObjectViewController.h"
#import "RuntimeViewController.h"
#import "RunLoopViewController.h"
#import "GCD-ViewController.h"
#import "DateViewController.h"
@interface NSObjectViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation NSObjectViewController{
    NSMutableArray *_dataSource;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    _NSobjectTableView.delegate = self;
    _NSobjectTableView.dataSource = self;
    self.view.backgroundColor = [UIColor whiteColor];
//
    [_NSobjectTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuseIdentifier"];
    _dataSource = [[NSMutableArray alloc] initWithCapacity:50];
    
    [_dataSource addObject:@"runtime"];
    [_dataSource addObject:@"runloop"];
    [_dataSource addObject:@"GCD"];
    [_dataSource addObject:@"NSDate"];
    [_dataSource addObject:@"KVO"];
    [_dataSource addObject:@"KVC"];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataSource.count;
}

- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier" forIndexPath:indexPath];
    if(!cell){
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"reuseIdentifier"];
    }
    cell.textLabel.text = _dataSource[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.row == 0){
        RuntimeViewController *runtimeVC = [RuntimeViewController new];
        runtimeVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:runtimeVC animated:YES];
    }
    
    if(indexPath.row == 1){
        RunLoopViewController *runLoopVC = [RunLoopViewController new];
        runLoopVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:runLoopVC animated:YES];
    }
    
    if(indexPath.row == 2){
        GCD_ViewController *gcdVC = [GCD_ViewController new];
        gcdVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:gcdVC animated:YES];
    }
    
    if(indexPath.row == 3){
        DateViewController *VC = [DateViewController new];
        VC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:VC animated:YES];
    }
    
}



@end
